package es.xpt.ysf.view.collections;

import java.util.ArrayList;
import java.util.List;


public class NumberCollectionsMethod extends ResolvedMethod {
	
	public NumberCollectionsMethod() {
		
	}
	
	@Override
	public Object invoke() {
		int min, max;
		if ( args.get(1) instanceof Long ) {
			max = ((Long)args.get(1)).intValue();
		} else {
			max = (Integer)args.get(1);
		}
		if ( args.get(0) instanceof Long ) {
			min = ((Long)args.get(0)).intValue();
		} else {
			min = (Integer)args.get(0);
		}
		
		List<Integer> list = new ArrayList<Integer>(max-min+1);
		for ( int i = min; i <= max; i++ ) {
			list.add(i);
		}
		return list;
	}
	
	@Override
	public boolean isReady() {
		return 2 == args.size();
	}
}
